import org.openqa.selenium.By;

import java.io.IOException;

/**
 * @projectName: The-examination-questionnaire-pass-test
 * @package: PACKAGE_NAME
 * @className: ShezhiPage
 * @author: Tongxinxin
 * @description: 个人设置页面功能测试
 * @date: 2025/9/22 0:35
 * @version: 1.0
 */
public class ShezhiPage extends Util{
    public ShezhiPage(String url) {
        super(url);
    }
    public static String url="http://8.155.1.153:8081/system/setting";
    //未登录状态下进入个人设置页面
    public void NoLoginIndividual() throws IOException {
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.top___1C1Zi > div.header___5xZ3f > span"));

        //判断是否返回登录页面
        String expect=driver.getTitle();

        getScreenShot(getClass().getName());
        assert expect.equals("问卷考试系统");
    }

    //登录状态下进入个人设置页面
    public void LoginIndividual() throws IOException {
        //进行登录
        driver.findElement(By.cssSelector("#username")).sendKeys("tong");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).click();

        //点击系统管理中的个人设置
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul > li.ant-menu-submenu.ant-menu-submenu-inline.ant-pro-base-menu-submenu.ant-menu-submenu-open.ant-menu-submenu-selected > div > span > div > span.anticon.ant-pro-base-menu-item-icon > span > svg")).click();
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).click();
        //输入姓名
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).sendKeys("tong11");
        //输入手机号
        driver.findElement(By.cssSelector("#phone")).sendKeys("17945612356");
        //输入邮箱
        driver.findElement(By.cssSelector("#email")).sendKeys("873387156@qq.com");
        //输入个人简介
        driver.findElement(By.cssSelector("#profile")).sendKeys("你好");
        //点击“提交”按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div > div > div.right___2jdGg > div.baseView___3sRG3 > div.left___GavW0 > form > div.ant-space.ant-space-horizontal.ant-space-align-center > div:nth-child(2) > button > span")).click();

        //检查是否修改成功，看用户名是否改变
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > header.ant-layout-header.ant-pro-layout-header.ant-pro-layout-header-fixed-header.ant-pro-layout-header-mix.ant-pro-layout-header-fixed-header-action.ant-pro-layout-header-header > div > div.ant-pro-global-header-right-content > div > div > div > span > div > span:nth-child(2)"));
        String el=driver.getTitle();

        getScreenShot(getClass().getName());
        assert el.equals("tong");
    }

    //修改失败--未填写用户名
    public void IndividualFail1() throws IOException {
        //进行登录
        driver.findElement(By.cssSelector("#username")).sendKeys("tong");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).click();

        //点击系统管理中的个人设置
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul > li.ant-menu-submenu.ant-menu-submenu-inline.ant-pro-base-menu-submenu.ant-menu-submenu-open.ant-menu-submenu-selected > div > span > div > span.anticon.ant-pro-base-menu-item-icon > span > svg")).click();
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).click();
        //输入手机号
        driver.findElement(By.cssSelector("#phone")).sendKeys("17945612356");
        //输入邮箱
        driver.findElement(By.cssSelector("#email")).sendKeys("873387156@qq.com");
        //输入个人简介
        driver.findElement(By.cssSelector("#profile")).sendKeys("你好");
        //点击“提交”按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div > div > div.right___2jdGg > div.baseView___3sRG3 > div.left___GavW0 > form > div.ant-space.ant-space-horizontal.ant-space-align-center > div:nth-child(2) > button > span")).click();

        //检查是否修改成功,检查是否有提示
        driver.findElement(By.cssSelector("#name_help > div"));
        String el=driver.getTitle();

        getScreenShot(getClass().getName());
        assert el.equals("请输入您的昵称");
    }

    //修改失败--未填写手机号
    public void IndividualFail2() throws IOException {
        //进行登录
        driver.findElement(By.cssSelector("#username")).sendKeys("tong");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).click();

        //点击系统管理中的个人设置
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul > li.ant-menu-submenu.ant-menu-submenu-inline.ant-pro-base-menu-submenu.ant-menu-submenu-open.ant-menu-submenu-selected > div > span > div > span.anticon.ant-pro-base-menu-item-icon > span > svg")).click();
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).click();
        //输入姓名
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).sendKeys("tong11");
        //输入邮箱
        driver.findElement(By.cssSelector("#email")).sendKeys("873387156@qq.com");
        //输入个人简介
        driver.findElement(By.cssSelector("#profile")).sendKeys("你好");
        //点击“提交”按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div > div > div.right___2jdGg > div.baseView___3sRG3 > div.left___GavW0 > form > div.ant-space.ant-space-horizontal.ant-space-align-center > div:nth-child(2) > button > span")).click();

        //检查是否修改成功,检查是否有提示
        driver.findElement(By.cssSelector("#phone_help > div"));
        String el=driver.getTitle();

        getScreenShot(getClass().getName());
        assert el.equals("请输入您的联系电话");
    }

    //修改失败--未填写邮箱
    public void IndividualFail3() throws IOException, IOException {
        //进行登录
        driver.findElement(By.cssSelector("#username")).sendKeys("tong");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).click();

        //点击系统管理中的个人设置
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > aside > div > div:nth-child(1) > ul > li.ant-menu-submenu.ant-menu-submenu-inline.ant-pro-base-menu-submenu.ant-menu-submenu-open.ant-menu-submenu-selected > div > span > div > span.anticon.ant-pro-base-menu-item-icon > span > svg")).click();
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).click();
        //输入姓名
        driver.findElement(By.cssSelector("#rc-menu-uuid-77701-2-\\/system-popup > li.ant-menu-item.ant-menu-item-selected.ant-menu-item-only-child.ant-pro-base-menu-menu-item > span > div > span")).sendKeys("tong11");
        //输入手机号
        driver.findElement(By.cssSelector("#phone")).sendKeys("17945612356");
        //输入个人简介
        driver.findElement(By.cssSelector("#profile")).sendKeys("你好");
        //点击“提交”按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div > div > div.right___2jdGg > div.baseView___3sRG3 > div.left___GavW0 > form > div.ant-space.ant-space-horizontal.ant-space-align-center > div:nth-child(2) > button > span")).click();

        //检查是否修改成功,检查是否有提示
        driver.findElement(By.cssSelector("#email_help > div"));
        String el=driver.getTitle();

        getScreenShot(getClass().getName());
        assert el.equals("请输入您的邮箱");
    }
}
